﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UceciSeznam.aspx.cs" Inherits="Sio.Mdm.Web.Organizacija.UceciSeznam" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>SIO - MDM :: Organizacija : Seznam učečih</title>

    <script type="text/javascript">
        var spoliRenderer = function(value) {
            var r = StoreSpoli.getById(value);
            if (Ext.isEmpty(r)) { return ""; }
            return r.data.Naziv;
        };
        var obcineRenderer = function(value) {
            var r = StoreObcine.getById(value);
            if (Ext.isEmpty(r)) { return ""; }
            return r.data.Naziv;
        };
        var posteRenderer = function(value) {
            var r = StorePoste.getById(value);
            if (Ext.isEmpty(r)) { return ""; }
            return r.data.PostnaStevilka + ' ' + r.data.Naziv;
        };
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <ext:Store ID="StoreObcine" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="ObcinaId">
                <Fields>
                    <ext:RecordField Name="ObcinaId" Type="Int" />
                    <ext:RecordField Name="Naziv" Type="String" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="StorePoste" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="PostaId">
                <Fields>
                    <ext:RecordField Name="PostaId" Type="Int" />
                    <ext:RecordField Name="PostnaStevilka" Type="Int" />
                    <ext:RecordField Name="Naziv" Type="String" />
                    <ext:RecordField Name="StevilkaNaziv" Type="String">
                        <Convert Handler="return record.PostnaStevilka+' '+record.Naziv;" />
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="StoreSpoli" runat="server">
        <Reader>
            <ext:ArrayReader IDProperty="SpolID">
                <Fields>
                    <ext:RecordField Name="SpolID" Type="Int" />
                    <ext:RecordField Name="Naziv" Type="String" />
                </Fields>
            </ext:ArrayReader>
        </Reader>
    </ext:Store>
    <ext:Viewport ID="Viewport1" runat="server" Layout="Fit">
        <Content>
            <sio:GridPanel ID="GridUceciSeznam" runat="server" StripeRows="true" TrackMouseOver="true"
                Width="700">
                <Plugins>
                    <ext:RowEditor ID="RowEditor1" runat="server" SaveText="Shrani" CancelText="Prekliči" ClicksToEdit="2">
                        <DirectEvents>
                            <AfterEdit OnEvent="UrediPodatke">
                                <ExtraParams>
                                    <ext:Parameter Mode="Raw" Name="data" Value="r.data" />
                                </ExtraParams>
                            </AfterEdit>
                        </DirectEvents>
                    </ext:RowEditor>
                    <ext:GridFilters runat="server">
                        <Filters>
                            <ext:StringFilter DataIndex="Ime" />
                            <ext:StringFilter DataIndex="Priimek" />
                            <ext:ListFilter DataIndex="Spol" Options="moški, ženska" />
                            <ext:NumericFilter DataIndex="IdmStevilka" />
                        </Filters>
                    </ext:GridFilters>
                </Plugins>
                <Store>
                    <ext:Store ID="StoreUceciSeznam" runat="server">
                        <SortInfo Field="Priimek" />
                        <Reader>
                            <ext:JsonReader IDProperty="IdmStevilka">
                                <Fields>
                                    <ext:RecordField Name="IdmStevilka" Type="Int" />
                                    <ext:RecordField Name="VlogaId" Type="Int" />
                                    <ext:RecordField Name="Ime" Type="String" />
                                    <ext:RecordField Name="Priimek" Type="String" />
                                    <ext:RecordField Name="Spol" Type="Int" />
                                    <ext:RecordField Name="Naslov" Type="String" />
                                    <ext:RecordField Name="PostaId" Type="Int" />
                                    <ext:RecordField Name="ObcinaId" Type="Int" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:RowNumbererColumn />
                        <ext:Column ColumnID="IdmStevilka" Hidden="true" Hideable="false" DataIndex="IdmStevilka">
                        </ext:Column>
                        <ext:Column ColumnID="VlogaId" Hidden="true" Hideable="false" DataIndex="VlogaId">
                        </ext:Column>
                        <ext:Column ColumnID="Ime" Header="Ime" DataIndex="Ime">
                            <Editor>
                                <ext:TextField runat="server" AllowBlank="false" MinLength="2" MinLengthText="Vpišite ime"
                                    BlankText="Vpišite ime" />
                            </Editor>
                        </ext:Column>
                        <ext:Column Header="Priimek" DataIndex="Priimek">
                            <Editor>
                                <ext:TextField runat="server" AllowBlank="false" MinLength="2" MinLengthText="Vpišite priimek"
                                    BlankText="Vpišite priimek" />
                            </Editor>
                        </ext:Column>
                        <ext:Column Header="Spol" DataIndex="Spol">
                            <Renderer Fn="spoliRenderer" />
                            <Editor>
                                <ext:ComboBox ID="cbSpoli" runat="server" TypeAhead="true" SelectOnFocus="true" Editable="true"
                                    Mode="Local" ForceSelection="true" StoreID="StoreSpoli" ValueField="SpolID" DisplayField="Naziv" />
                            </Editor>
                        </ext:Column>
                        <ext:Column Header="Naslov" DataIndex="Naslov" Width="150">
                            <Editor>
                                <ext:TextField runat="server" AllowBlank="false" MinLength="3" MinLengthText="Vpišite naslov"
                                    BlankText="Vpišite naslov" />
                            </Editor>
                        </ext:Column>
                        <ext:Column Header="Občina" DataIndex="ObcinaId" Width="150">
                            <Renderer Fn="obcineRenderer" />
                            <Editor>
                                <ext:ComboBox ID="cbObcine" runat="server" TypeAhead="true" SelectOnFocus="true"
                                    Editable="true" Mode="Local" ForceSelection="true" StoreID="StoreObcine" ValueField="ObcinaId"
                                    DisplayField="Naziv" />
                            </Editor>
                        </ext:Column>
                        <ext:Column Header="Pošta" DataIndex="PostaId" Width="150">
                            <Renderer Fn="posteRenderer" />
                            <Editor>
                                <ext:ComboBox ID="cbPoste" runat="server" TypeAhead="true" SelectOnFocus="true" Editable="true"
                                    Mode="Local" ForceSelection="true" StoreID="StorePoste" ValueField="PostaId"
                                    DisplayField="StevilkaNaziv" />
                            </Editor>
                        </ext:Column>
                        <ext:CommandColumn Width="35">
                            <Commands>
                                <ext:GridCommand Icon="NoteEdit" CommandName="Uredi">
                                    <ToolTip Text="Uredi" />
                                </ext:GridCommand>
                            </Commands>
                        </ext:CommandColumn>
                    </Columns>
                </ColumnModel>
                <Listeners>
                    <Command Handler="openTab('../Uporabnik/Akter.aspx', 'Učeči '+record.data.Ime+' '+record.data.Priimek, {idm: record.id }, 'akter'+record.id);" />
                </Listeners>
                <SelectionModel>
                    <ext:CheckboxSelectionModel runat="server" />
                </SelectionModel>
                <TopBar>
                    <ext:Toolbar ID="Toolbar1" runat="server">
                        <Items>
                            <sio:Button runat="server" ID="Add" Text="Dodaj" Icon="Add">
                                <Listeners>
                                    <Click Handler="#{AddUceci}.show();" />
                                </Listeners>
                                <%--showDialog(#{RazredAddUceci}, {letoid: Ext.urlDecode(window.location.search.substring(1)).letoid, razredid: Ext.urlDecode(window.location.search.substring(1)).razredid });" /></Listeners>--%>
                            </sio:Button>
                            <sio:Button runat="server" ID="Remove" Text="Odstrani" Icon="Delete">
                                <DirectEvents>
                                    <Click OnEvent="OdstraniUcece" After="#{StoreUceciSeznam}.reload();">
                                        <Confirmation ConfirmRequest="true" Message="Izbrišem izbrane učeče?" />
                                        <ExtraParams>
                                            <ext:Parameter Name="selected" Mode="Raw" Value="Ext.encode(#{GridUceciSeznam}.getRowsValues({selectedOnly:true}))" />
                                        </ExtraParams>
                                    </Click>
                                </DirectEvents>
                            </sio:Button>
                            <ext:ToolbarSeparator />
                            <sio:Button runat="server" ID="SyncToLdap" Text="Sinhroniziraj AD/Ldap" ToolTip="Sinhroniziraj izbrani razred v AD/Ldap"
                                Icon="AsteriskYellow">
                                <DirectEvents>
                                    <Click OnEvent="SyncToLdapEvent">
                                        <ExtraParams>
                                            <ext:Parameter Name="selected" Mode="Raw" Value="Ext.encode(#{GridUceciSeznam}.getRowsValues({selectedOnly:true}))" />
                                        </ExtraParams>
                                    </Click>
                                </DirectEvents>
                            </sio:Button>
                            <sio:Button runat="server" ID="DeleteFromLdap" Text="Briši iz AD/Ldap" ToolTip="Briši izbrani razred iz AD/Ldap"
                                Icon="AsteriskRed">
                                <DirectEvents>
                                    <Click OnEvent="DeleteFromLdapEvent">
                                        <ExtraParams>
                                            <ext:Parameter Name="selected" Mode="Raw" Value="Ext.encode(#{GridUceciSeznam}.getRowsValues({selectedOnly:true}))" />
                                        </ExtraParams>
                                    </Click>
                                </DirectEvents>
                            </sio:Button>
                            <ext:ToolbarSeparator />
                            <ext:Button ID="btnUvozi" runat="server" Text="Uvoz podatkov" Icon="Wand">
                                <Menu>
                                    <ext:Menu runat="server">
                                        <Items>
                                            <ext:MenuItem ID="btnUvozUceci" runat="server" Text="Uvoz iz Excel datoteke" Icon="PageWhiteExcel">
                                                <Listeners>
                                                    <Click Handler="#{UvozCarovnik}.show();" />
                                                </Listeners>
                                            </ext:MenuItem>
                                        </Items>
                                    </ext:Menu>
                                </Menu>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
            </sio:GridPanel>
        </Content>
    </ext:Viewport>
    <%--<sio:Window runat="server" ID="RazredAddUceci"
		Width="600"
		Height="400"
		Url="NovUceci.aspx">
	
	</sio:Window>--%>
    <%--showDialog(#{RazredAddUceci}, {letoid: Ext.urlDecode(window.location.search.substring(1)).letoid, 
	razredid: Ext.urlDecode(window.location.search.substring(1)).razredid });" /></Listeners>--%>
    <sio:Dialog runat="server" ID="AddUceci" Width="600" Height="400" Url="NovUceci.aspx"
        DialogButtons="SaveClose" Title="Dodaj učečega">
        <Parameters>
            <ext:Parameter Name="letoid" Value="Ext.urlDecode(window.location.search.substring(1)).letoid"
                Mode="Raw" />
            <ext:Parameter Name="razredid" Value="Ext.urlDecode(window.location.search.substring(1)).razredid"
                Mode="Raw" />
        </Parameters>
        <Listeners>
            <ButtonClicked Handler="debugger;" />
            <Close Handler="#{StoreUceciSeznam}.reload();" />
            <ClientNotify Handler="debugger;" />
        </Listeners>
    </sio:Dialog>
    <sio:Dialog runat="server" ID="UvozCarovnik" Width="1000" Height="400" Url="UvozCarovnik.aspx" Title="Uvoz podatkov o učečih iz excela"
        DialogButtons="Close">
    </sio:Dialog>
    </form>
</body>
</html>
